from itertools import combinations

# 给定的数
nums = [0x27, 0x29, 0x30, 0x31, 0x7, 0x5, 0x3d, 0x22, 0xc, 0x2a, 0xd, 0x16, 0x3, 0x4, 0x2c]
target = 0x5a  # 目标值

# 检查所有可能的组合
for r in range(1, len(nums) + 1):
    for combo in combinations(nums, r):
        if sum(combo) == target:
            # 以16进制格式打印子集
            print(f"找到一个子集: {', '.join(f'0x{c:x}' for c in combo)}")